/**
* main functions
* copyright@Catosoft.com reserved, 2016
* 2016.06.16, created by Eric.Wang
*/

var config = {
	enterGroup: {
		path: '/js/enterGroupChart.js',
		load: true
	},
	dataInput: {
		path: '/js/dataInputChart.js',
		load: false
	},
	dataCheck: {
		path: '/js/dataCheckChart.js',
		load: false
	},
	dataLock: {
		path: '/js/dataLockChart.js',
		load: false
	},
	doctorAudit: {
		path: '/js/doctorAuditChart.js',
		load: false
	},
	question: {
		path: '/js/questionChart.js',
		load: false
	},
	uncompleteForm: {
		path: '/js/uncompleteFormChart.js',
		load: false
	},
	workloadForm: {
		path: '/js/workloadFormChart.js',
		load: false
	},
	windowForm: {
		path: '/js/windowFormChart.js',
		load: false
	},
	edcOption: {
		path: '/js/edcOptionChart.js',
		load: false
	},
	enterGroupStats: {
		path: '/js/enterGroupStatsChart.js',
		load: false
	},
	productOperation: {
		path: '/js/projectOperationChart.js',
		load: false
	},
	inputTimeStats: {
		path: '/js/inputTimeStatsChart.js',
		load: false
	},
	userManage: {
		path: '/js/userManageChart.js',
		load: false
	},
	labSpec: {
		path: '/js/labSpecChart.js',
		load: false
	},
	demo: {
		path: '/js/demo.js',
		load: false
	}
};

$(function(){
	$('a[data-toggle="tab"]').on('shown.bs.tab', function(){
		
		// change dropdown button text
		$('#dropdown-toggle').html($(this).html() + '<span class="caret"></span>');

		// reflow charts when change nav tab
		var charts = $(this).attr('href');
		var tabId = charts.substr(1);
		var configItem = config[tabId];
		if (!configItem) {
			return false;
		}
		var loaded = configItem.load;
		if (!loaded) {
			var path = configItem.path;
			$('body').append('<script src="' + path + '"></script');
			configItem.load = true;
		}
		/*charts += '>div.block';
		$(charts).each(function(){
			if($(this).highcharts()){
				$(this).highcharts().reflow();
			}
		});*/
	});
});